package com.nnnu.wsnackshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nnnu.wsnackshop.pojo.entity.CartItems;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 购物车明细 Mapper 接口
 * </p>
 *
 * @author zk
 * @since 2025-05-14
 */
@Mapper
public interface CartItemsMapper extends BaseMapper<CartItems> {

    /**
     * 查询购物车商品总数量
     */
    @Select("SELECT IFNULL(SUM(quantity),0) FROM cart_items WHERE cart_id = #{cartId}")
    Integer sumCartQuantityByCartId(@Param("cartId") Integer cartId);

}
